<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:pr="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:cc="http://java.sun.com/jsf/composite">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="source" required="true"/>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <h:form>
                <pr:dataTable id="orders" value="#{cc.attrs.source}" var="order">

                    <pr:column sortBy="#{order.trackingNumber}">
                        <f:facet name="header">
                            <h:outputText value="Order#"/>
                        </f:facet>
                        <h:outputText value="#{order.trackingNumber}"/>
                    </pr:column>

                    <pr:column sortBy="#{order.orderDate}">
                        <f:facet name="header">
                            <h:outputText value="Date"/>
                        </f:facet>
                        <h:outputText value="#{order.orderDate}"/>
                    </pr:column>

                    <pr:column sortBy="#{order.isPaid()}">
                        <f:facet name="header">
                            <h:outputText value="Is paid"/>
                        </f:facet>
                        <h:outputText value="#{order.isPaid()}"/>
                    </pr:column>

                    <pr:column sortBy="#{order.user.name}">
                        <f:facet name="header">
                            <h:outputText value="Ordered By"/>
                        </f:facet>
                        <h:outputText value="#{order.user.name}"/>
                    </pr:column>
                    
                    <pr:column>
                        <f:facet name="header">
                            <h:outputText value="View Order"/>
                        </f:facet>
                            <h:commandButton value="View" action="#{orderBackingBean.view(order)}"/>
                    </pr:column>
                </pr:dataTable>
            </h:form>
    </cc:implementation>
</html>